package com.purengage.ipilih;

import java.util.ArrayList;

import com.markupartist.android.widget.ActionBar;
import com.markupartist.android.widget.ActionBar.Action;
import com.markupartist.android.widget.ActionBar.IntentAction;
import com.purengage.ipilih.lib.DialogBox;
import com.purengage.ipilih.lib.EntryAdapterDetailRelawan;
import com.purengage.ipilih.lib.EntryItem;
import com.purengage.ipilih.lib.Item;
import com.purengage.ipilih.lib.SectionItem;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

public class AddRelawan extends Activity implements OnItemClickListener {

	ArrayList<Item> items = new ArrayList<Item>();
	ListView listview;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_edit_detail_relawan);
		final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
		actionBar.setTitle("Relawan");
		actionBar.setHomeAction(new IntentAction(this, Relawan
				.createIntent(this), R.drawable.ic_action_back));

		final Action CancelAction = new IntentAction(this, new Intent(this,
				Relawan.class), android.R.drawable.ic_menu_close_clear_cancel);
		actionBar.addAction(CancelAction);

		final Action SaveAction = new IntentAction(this, new Intent(this,
				Relawan.class), android.R.drawable.ic_menu_save);
		actionBar.addAction(SaveAction);				
		
		listview = (ListView) findViewById(R.id.list_edit_relawan);
		items.add(new SectionItem("Area Kerja"));
		items.add(new EntryItem(0, "Propinsi", "Jawa Timur", null, null));
		items.add(new EntryItem(0, "Kabupaten", "Bojonegoro", null, null));
		items.add(new EntryItem(0, "Kecamatan", "Balen", null, null));
		items.add(new EntryItem(0, "Desa", "Semua", null, null));
		items.add(new EntryItem(0, "Fungsi", "Relawan", null, null));
		items.add(new SectionItem("Identitas"));
		items.add(new EntryItem(0, "Tanggal Lahir", "Belum Diisi", null, null));
		items.add(new EntryItem(0, "Jenis Kelamin", "Belum Diisi", null, null));
		items.add(new EntryItem(0, "Nomor Handphone", "Belum Diisi", null, null));
		items.add(new EntryItem(0, "Alamat", "Belum Diisi", null, null));
		items.add(new SectionItem("Akses"));
		items.add(new EntryItem(0, "ID Login", "Khusus Koordinator", null, null));
		items.add(new EntryItem(0, "PIN", "Khusus Koordinator", null, null));
		items.add(new EntryItem(0, "Status", "Aktif", null, null));
		
		EntryAdapterDetailRelawan adapter = new EntryAdapterDetailRelawan(this,
				items);
		listview.setAdapter(adapter);
		listview.setOnItemClickListener(this);

	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int position,
			long arg3) {
		// TODO Auto-generated method stub
		DialogBox dbox = new DialogBox(AddRelawan.this);
		EntryItem item = (EntryItem) items.get(position);
		Toast.makeText(this, "You clicked " + item.title, Toast.LENGTH_SHORT)
				.show();
		switch (position) {
		case 1:
			//dbox.Pilihan2Dialog("Propinsi", {"Pilihan 1", "Pilihan 2"});
			break;
		case 2:
			//dbox.Pilihan2Dialog("Kabupaten", "Pilihan 1", "Pilihan 2");
			break;
		case 3:
			//dbox.Pilihan2Dialog("Kecamatan", "Pilihan 1", "Pilihan 2");
			break;
		case 4:
			//dbox.Pilihan2Dialog("Desa", "Pilihan 1", "Pilihan 2");
			break;
		case 7:
			dbox.DatePopup("Tanggal Lahir");
			break;
		case 8:
			//dbox.Pilihan2Dialog("Jenis Kelamin", "Laki-Laki", "Perempuan");
			break;
		case 9:
			//dbox.textFieldPopup("Nomor Handphone");
			break;
		case 10:
			//dbox.textFieldPopup("Alamat");
			break;
		default:
			break;
		}

	}
}
